package com.nc.delivery_project.shared.locator;

import com.google.web.bindery.requestfactory.shared.Locator;
import com.nc.delivery_project.server.domain.Cargo;
import com.nc.delivery_project.server.service.CargoService;
import com.nc.delivery_project.shared.servicelocator.CargoServiceLocator;

/**
 * Created with IntelliJ IDEA.
 * User: Natalie D.
 * Date: 1/26/15
 * Time: 9:32 PM
 */
public class CargoLocator extends Locator<Cargo, Integer> {
    @Override
    public Cargo create(Class<? extends Cargo> clazz) {
        return new Cargo();
    }

    @Override
    public Cargo find(Class<? extends Cargo> clazz, Integer id) {
        return ((CargoService) new CargoServiceLocator().getInstance(null)).read(id);
    }

    @Override
    public Class<Cargo> getDomainType() {
        return Cargo.class;
    }

    @Override
    public Integer getId(Cargo domainObject) {
        return domainObject.getId();
    }

    @Override
    public Class<Integer> getIdType() {
        return Integer.class;
    }

    @Override
    public Object getVersion(Cargo domainObject) {

        return domainObject.getId();
    }
}
